//
//  ZhuBoHeadView.m
//  喜马拉雅FM
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 lanou.com. All rights reserved.
//

#import "ZhuBoHeadView.h"
#import "UIImageView+WebCache.h"

@interface ZhuBoHeadView ()

@property (nonatomic, retain) UIImageView *backGroundLogo;
@property (nonatomic, retain) UIImageView *imageMobileSmallLogo;
@property (nonatomic, retain) UIView *visualView;
@property (nonatomic, retain) UILabel *labelNickName;
@property (nonatomic, retain) UILabel *labelPersonalSignature;



@end

@implementation ZhuBoHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {

        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
   
    // 毛玻璃视图层.
    self.backGroundLogo = [[UIImageView alloc]init];
    self.backGroundLogo.image = [UIImage imageNamed:@"2.jpg"];
    self.backGroundLogo.frame = self.bounds;
    self.backGroundLogo.userInteractionEnabled = YES;
    [self addSubview:self.backGroundLogo];
    [self.backGroundLogo release];
    
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:2];
    self.visualView = [[UIVisualEffectView alloc]initWithEffect:blur];
    self.visualView.frame = self.bounds;
    [self.backGroundLogo addSubview:self.visualView];
    [self.visualView release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(20, 30, 32, 32);
    [button setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [self.visualView addSubview:button];
    [button addTarget:self action:@selector(handleBack:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIView *smallLogoBackGround = [[UIView alloc]initWithFrame:CGRectMake((self.bounds.size.width - 106) / 2, 50, 106, 106)];
    smallLogoBackGround.backgroundColor = [UIColor grayColor];
    [self.visualView addSubview:smallLogoBackGround];
    smallLogoBackGround.layer.cornerRadius = 53;
    smallLogoBackGround.layer.masksToBounds = YES;
    [smallLogoBackGround release];
    
    self.imageMobileSmallLogo = [[UIImageView alloc]initWithFrame:CGRectMake((self.bounds.size.width - 100) / 2, 53, 100, 100)];
    self.imageMobileSmallLogo.backgroundColor = [UIColor whiteColor];
    [self.visualView addSubview:self.imageMobileSmallLogo];
    self.imageMobileSmallLogo.layer.cornerRadius = 50;
    self.imageMobileSmallLogo.layer.masksToBounds = YES;
    [self.imageMobileSmallLogo release];
    
    
    self.labelNickName = [[UILabel alloc]initWithFrame:CGRectMake((self.bounds.size.width - 100) / 2, 166, 100, 30)];
    self.labelNickName.font = [UIFont systemFontOfSize:20];
    [self.visualView addSubview:self.labelNickName];
    self.labelNickName.textAlignment = NSTextAlignmentCenter;
    self.labelNickName.text = @"美 龙 英 语";
    self.labelNickName.textColor = [UIColor whiteColor];
    [self.labelNickName release];
    
    self.labelPersonalSignature = [[UILabel alloc]initWithFrame:CGRectMake((self.bounds.size.width - 300) / 2, 200, 300, 45)];
    [self.visualView addSubview:self.labelPersonalSignature];
    self.labelPersonalSignature.textAlignment = NSTextAlignmentCenter;
    self.labelPersonalSignature.numberOfLines = 0;
    self.labelPersonalSignature.textColor = [UIColor grayColor];
    [self.labelPersonalSignature release];
    
}

- (void)handleBack:(UIButton *)button {

    id object = [self nextResponder];
    while (![object isKindOfClass:[UIViewController class]] && object != nil ) {
        object = [object nextResponder];
    }
    UIViewController *vc = (UIViewController *)object;
    [vc.navigationController popViewControllerAnimated:YES];
    [vc.navigationController setNavigationBarHidden:NO animated:YES];
    

}

- (void)passDictionary:(NSMutableDictionary *)dic {

    [self.backGroundLogo sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"backgroundLogo"]] placeholderImage:[UIImage imageNamed:@"2.jpg"]];

    [self.imageMobileSmallLogo sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"mobileSmallLogo"]] placeholderImage:[UIImage imageNamed:@"2.jpg"]];
    
    self.labelNickName.text = [dic objectForKey:@"nickname"];
    self.labelPersonalSignature.text = [dic objectForKey:@"personalSignature"];



}



@end
